<?php


namespace App\Transformers\Member;


use App\Models\MemberCardBatch;
use League\Fractal\TransformerAbstract;

class MemberCardBatchTransFormer extends TransformerAbstract
{
    protected $availableIncludes =['membercard'];
    public function transform($data)
    {
    return [
          'id'=>$data->id,
          'title' => $data->title?? '',
          'total_num' => $data->total_num ?? '',
          'use_num' => $data->use_num?? '',
          'use_start_time' => $data->use_start_time ?? '',
          'use_end_time' => $data->use_end_time ?? '',
          'use_day' => $data->use_day ?? '',
          'sort' => $data->sort ?? '',
          'qrcode' => $data->qrcode ?? '',
          'status' => $data->status ?? '',
          'remark' => $data->remark ?? '',
          'created_at' => $data->created_at ? $data->created_at->format("Y-m-d H:i:s") : '',
          'updated_at' => $data->updated_at ? $data->updated_at->format("Y-m-d H:i:s") : '',
    ];

    }

    /**
     * 批次所包含的会员卡
     */
        public function includeMemberCard(MemberCardBatch $memberCardBatch){
            return $this->collection($memberCardBatch->membercard,new MemberCardTransFormer());
        }
}
